<!-- 设备管理页面 -->
<template>
    <view>
		
		<u-navbar height="60" bgColor="#0081ff">
			<!-- #ifdef MP-WEIXIN -->
			<view class="u-nav-slot margin-top-xl" slot="left">
			</view>
			<!-- #endif -->
			<view slot="center" class="u-nav-slot" style="display: flex; flex-direction: column;align-items: center;">
				<view style=" font-size: 20px; color: #FFFFFF;">设备管理</view>
			</view>
		</u-navbar>
		
        <view class="cu-list menu card-menu margin-top xl-border" v-for="(item,index) in deviceList" :key="index"
            @tap="toDeviceInfo(item.deviceId,item.shareDevice)">
            <view class="cu-item arrow">
                <view class="content flex align-center">
                    <image class="round" style="width: 6vh;height: 6vh;" :src="imgUrl+ item.image"></image>
                    <view class="flex flex-direction margin-left-sm">
                        <text class="text-grey">{{item.deviceName}}</text>
                        <text class="text-grey text-sm">{{item.deviceId}}</text>
                    </view>
                </view>
            </view>
        </view>

    </view>
</template>

<script>
    export default {
        data() {
            return {
				imgUrl: this.imgUrl,
                deviceList: null,
            }
        },
        onLoad: function(option) { //option为object类型，会序列化上个页面传递的参数
            this.getDeviceList()
        },
        methods: {
            //获取用户的设备列表
            getDeviceList() {
                this.$http.request({
                    url: 'app/device/listAll',
                    method: 'GET',
                    success: (data) => {
                        if (data.data && data.data.code == 0) {
                            this.deviceList = data.data.list
                        }
                    }
                })
            },
            toDeviceInfo(deviceId, isShare) {
                uni.navigateTo({
                    url: '/pages/basics/itemInfo?deviceId=' + deviceId + '&isShare=' + isShare
                })

            },
        }
    }
</script>

<style>

</style>
